ANTIGEN="$HOME/.local/bin/antigen.zsh"

if [ ! -f "$ANTIGEN" ]; then
    echo "Installing antigen ..."
    URL="https://raw.githubusercontent.com/zsh-users/antigen/master/bin/antigen.zsh"
    TMPFILE="/tmp/antigen.zsh"

    if [ -x "$(which curl)" ]; then
        curl -L "$URL" -o "$TMPFILE"
    elif [ -x "$(which wget)" ]; then
        wget "$URL" -O "$TMPFILE"
    else
        echo "error: please install curl or wget"
        exit
    fi

    if [ ! $? -eq 0 ]; then
        echo "download antigen.zsh ($URL) failed"
        exit
    fi;

    echo "move $TMPFILE to $ANTIGEN"
    mv "$TMPFILE" "$ANTIGEN"
fi

if [ ! -d "$HOME/.fzf" ] ; then
    echo "Installing fzf ..."
    git clone --depth 1 https://github.com/junegunn/fzf.git $HOME/.fzf
    $HOME/.fzf/install --key-bindings --completion --no-update-rc
fi

[ -f "$HOME/.local/etc/init.sh" ] && source "$HOME/.local/etc/init.sh"
# exit for non-interactive shell
[[ $- != *i* ]] && return

#export TERM="xterm-256color"

# Initialize command prompt
export PS1="%n@%m:%~%# "

# Initialize antigen
source "$ANTIGEN"

antigen use oh-my-zsh

antigen bundle zsh-users/zsh-autosuggestions
antigen bundle zsh-users/zsh-syntax-highlighting
antigen bundle zsh-users/zsh-completions
antigen bundle rupa/z z.sh
antigen bundle webyneter/docker-aliases.git

antigen apply

alias lk="ls -lha --group-directories-first"
alias ll="ls -al"

bindkey -s '\eo' 'cd ..\n'
bindkey -s '\e;' 'lk\n'

setopt HIST_IGNORE_ALL_DUPS
[ -f $HOME/.fzf.zsh ] && source $HOME/.fzf.zsh
